package me.zhengjie.util;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

@Component
public class LoginUtil {
    /**
     * 获取当前登录的用户信息
     * @return 当前登录的用户名
     */
    public static String getLoginUser(){
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        return authentication.getName();
    }
}
